// pages/mine/bbs/favour/favour.js
import { HTTP } from '../../../../utils/http.js'
let ajax = new HTTP()
const app = getApp()

Page({
    data: {
        currentTab: 0,
        winHeight: "",
        favourTitle: [{
                text: '我的赞',
                id: 0
            },
            {
                text: '我的收藏',
                id: 1
            }
        ],
        favourContent: []
    },
    onLoad(options) {
        wx.showLoading({
            title: '加载中',
        })
        wx.getSystemInfo({
            success: (res) => {
                let clientHeight = res.windowHeight
                let clienWidth = res.windowWidth
                let rpxR = 750 / clienWidth
                let calc = clientHeight * rpxR
                console.log(calc)
                this.setData({
                    winHeight: calc - 95
                })
            },
        })
        this._getMybbsprize();
    },
    // 点击列表
    switchNav(event) {
        let cur = event.currentTarget.dataset.current
        if (this.data.currentTab === cur) {
            return false
        } else {
            this.setData({
                currentTab: cur
            })
        }
    },
    // 左右滑动
    switchTab(event) {
        this.setData({
            currentTab: event.detail.current
        })
    },
    _getMybbsprize() {
        let memberid = wx.getStorageSync("memberid")
        ajax.request({
            method: "GET",
            url: "mycenter",
            data: {
                actname: 'mybbsprize',
                memberid: memberid,
                p: 0
            },
            success: (res) => {
                wx.hideLoading()
                if (res.rescode == "0000") {
                    this.setData({
                        favourContent: res.data
                    })

                }
            }
        })
    },
    onVideoTap(event) {
        let artId = event.currentTarget.dataset.postid
        let title = event.currentTarget.dataset.posttitle
        wx.navigateTo({
            url: '/pages/community/detail/detail?id=' + artId + '&title=' + title,
        })
    }
})